<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //父类
        function User(name,age){
            this.name=name;
            this.age=age;
        }
        User.prototype.show=function(){
               console.log(this.name,this.age);
        };


        //子类
        function Admin(name,age){
                User.call(this,name,age);//使用call访问父类的构造器
        }
        Admin.prototype=Object.create(User.prototype);//继承父类

        //new 
        let admin=new Admin("唐玮",18);
        admin.show();//唐玮 18


        //假设还有一个公司的子类
        function Company(...args){
            User.apply(this,args)//后面传的是一个数组
        }
        Company.prototype=Object.create(User.prototype);
        let com= new Company("何彩霞");
        com.show();//何彩霞 undefined
    </script>
</body>
</html>